<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>change background color on click</title>
</head>

<body>
    <input id="ipt" type="checkbox">
    <label for="ipt">深夜模式</label>

    <script src="js/jquery-3.7.1.min.js"></script>
    <script>
        // function changeBgColor() {
        //     document.body.style.backgroundColor = "blue";
        // }

        $('#ipt').change(function () {
            if ($('#ipt').prop('checked')) {
                $('body').css("background-color", "blue");
            } else {
                $('body').css("background-color", "white");
            }
        })
    </script>
</body>

</html>